Skip to content

[algolia-insights] add support for auth user token and product list viewed #3104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jkaho
Copy link
Contributor

@jkaho jkaho commented Jul 24, 2025

Add support for the Algolia Insights API optional authenticatedUserToken field.

Add support for the Segment Product List Viewed event.

Related doc change: segmentio/segment-docs#7791

Testing

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

@joe-ayoub-segment
Copy link
Contributor

Thanks for the PR @jkaho . I'll schedule time to review.

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho I had a quick scan. Did you mean to include the file at this location? packages/browser-destinations/destinations/algolia-plugins/src/algoliaInsights/generated-types.ts

@jkaho
Copy link
Contributor Author

jkaho commented Jul 24, 2025

Thanks @joe-ayoub-segment! Sorry, I missed that–no I did not mean to include it. Removed 👍

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho please run this command and commit the changes

yarn types

@joe-ayoub-segment
Copy link
Contributor

Hi again @jkaho , I reviewed the PR.

Regarding adding the new field authenticatedUserToken:

  • Looks like this field is to capture an identifier for a user when the user is known to the customer. Does this mean that the userToken field was always intended to capture an anonymous user's anonymous identifier? because it used to try and capture the main identifier and only fell back to the anonymous one.
  • How will this change affect customers who are already sending the Segment userId (which is the id for users who are known to the customer) to the userToken field? They won't be populating the authenticatedUserToken field (so it will be undefined).
  • Are you able to provide evidence of testing this please?

Regarding the new Action:

  • I don't think the default mapping used for ObjectIds field will work. Have you tested it locally?
  • Are you able to provide evidence of testing this please?

Best regards,
Joe

@joe-ayoub-segment
Copy link
Contributor

hi again @jkaho can you please also run yarn types and commit the updated file please?

@jkaho
Copy link
Contributor Author

jkaho commented Aug 12, 2025

Hey @joe-ayoub-segment, appreciate the review!

  • We added the authenticatedUserToken field a couple of years ago now, before which the userToken field was intended to capture either the auth or anon token. The addition of the new auth field meant we changed the way we recommend users send us user identifiers, though this wasn't a breaking change. If users don't set the auth token field, we will take the value from the user token field (which is required). Again, this change was made a little while ago now and neglecting to add support for it to our Segment connector was an oversight on our part. Is there anything you would recommend in terms of documentation to mitigate potential confusion?
  • I have tested the object IDs mapping via the Actions Tester, and it does seem to map the correct values as per the highlighted portions in the screenshot below. Have I misinterpreted something here? Though, I am noticing that the input badge doesn't show in the user configuration UI..
Screenshot 2025-08-12 at 10 32 37 am

@joe-ayoub-segment
Copy link
Contributor

Hey @joe-ayoub-segment, appreciate the review!

  • We added the authenticatedUserToken field a couple of years ago now, before which the userToken field was intended to capture either the auth or anon token. The addition of the new auth field meant we changed the way we recommend users send us user identifiers, though this wasn't a breaking change. If users don't set the auth token field, we will take the value from the user token field (which is required). Again, this change was made a little while ago now and neglecting to add support for it to our Segment connector was an oversight on our part. Is there anything you would recommend in terms of documentation to mitigate potential confusion?
  • I have tested the object IDs mapping via the Actions Tester, and it does seem to map the correct values as per the highlighted portions in the screenshot below. Have I misinterpreted something here? Though, I am noticing that the input badge doesn't show in the user configuration UI..
Screenshot 2025-08-12 at 10 32 37 am

Hi @jkaho , that's correct, the 'badge' contains the mapping details the user gets to see in the UI. Our UI doesn't support this type of mapping, so while the mapping itself might work, it breaks the UI.

I suggest changing the mapping to something like this

{
        '@path': '$.properties.products.product_ids'
}

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho thanks for explaining the history of userToken and authenticatedUserToken.
I think the change is safe. i.e it will continue to work for customers who already have the Integration set up. And it will work for customers who set it up from the post deployment of this PR.

If you like, you could add a note to the Algolia Insights Integration's docs page to explain this change in a little more details.

Just add a new header and paragraph explaining what customers need to know. Our docs team will review and deploy the change.

Best regads,
Joe

@jkaho
Copy link
Contributor Author

jkaho commented Aug 14, 2025

@joe-ayoub-segment

{
       '@path': '$.properties.products.product_ids'
}

Hm, this doesn't conform to Segment's ecommerce spec though, right? I've updated the product ID mapping to be the same as the conversion events (purchase, add to cart) where we map the products object array and then apply a custom transformation after the payload is resolved. I feel like this approach might be preferable as it's consistent with our other event mappings.
Screenshot 2025-08-14 at 6 07 29 pm

Also pushed a change to the docs PR regarding the user tokens.

Let me know what you think!

@joe-ayoub-segment
Copy link
Contributor

Thanks @jkaho this looks good. Only a nit issue left. Please see the comments.
Best regards,
Joe

@jkaho
Copy link
Contributor Author

jkaho commented Aug 18, 2025

@joe-ayoub-segment thanks Joe, comments resolved. Let me know if any other changes are required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants